package org.cwnuit.course.util;
import java.lang.reflect.Method;

/**
 * 反射工具类
 * @author john
 */
public class ReflectionUtils
{

	/**
	 * 循环向上转型, 获取对象的getDeclaredMethod.
	 * @param object
	 * @param fieldName
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public static Method getDeclaredMethod(Object object, String fieldName)
	{
		Class c = (Class)object;
		Method[] m = c.getDeclaredMethods();
		for(Method method:m){
			if(method.getName().equals(fieldName)){
				return method;
			}
		}
		return null;
	}
	
}
